<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="125">
            <Row  class="query-form">
                <Col span="8">
                    <FormItem label="所属单位：">
                        <cascaderDom ref="queryOrgCascader" @setOrgInfo="setOrgId" :rootOrgId="companyId" class="query-form-el" :orgTree="true"></cascaderDom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="年度：" prop="year" >
                        <DatePicker class="query-form-el" type="year" v-model="dataToQuery.year1" :clearable="false"
                                    @on-change="()=>{if(dataToQuery.year1 instanceof Date){dataToQuery.year = dataToQuery.year1.getFullYear().toString()}}"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8" v-if="!switchFlag">
                    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reset1" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
                <Col span="8" v-else>
                    <FormItem label="是否上传：">
                        <Select v-model='dataToQuery.isTrue' clearable class='query-form-el'>
                            <Option value="1">已上传</Option>
                            <Option value="0">未上传</Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="企业搜索：">
                        <Input class="query-form-el" placeholder="输入公司名称" v-model="dataToQuery.orgName"></Input>
                    </FormItem>
                </Col>
               <!-- <Col  span="8" >
                    <FormItem label='正副处：'>
                        <Select v-model='dataToQuery.adminLevel' clearable class='query-form-el'>
                            <Option value="AD-000001000000001">正处</Option>
                            <Option value="AD-000001000000002">副处</Option>
                            <Option value="AD-000001000000003">副处以下</Option>
                        </Select>
                    </FormItem>
                </Col> -->
                <Col span="8" offset=8>
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset1" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
               :loading='pageStatus.loading'
               border :columns="columns1" :data="dataTable">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>


    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                queryMeetingSelectModal:false,
                columns1: [
                    {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {key: 'twoLevelName', title: '二级集团', fixed: 'left', align: 'center', minWidth: 200},
                    {key: 'companyName', title: '单位', align: 'center', minWidth: 200},
                    // {key: 'levelName', title: '正副处', align: 'center', minWidth: 100},
                    {key: 'number', title: '问题整改方案上传情况', align: 'center', minWidth: 100,
                        render: (h, params) => {
                            return h('span', params.row.number > 0 ? '已上传' : '未上传')
                        }
                    },
                ],
                tableHeight: 10,
                companyId:'',
                buttonLoading:false,
                // api
                queryUrl: Api.topicWork+'/statistic',

                topics: [],
                topicActivityId: ''
            }
        },
        mounted() {
            this.companyId=sessionStorage('userId').getObject('userId').companyId
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.dataToQuery.year1 = new Date()
            this.dataToQuery.year = new Date().getFullYear().toString()
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            query() {
                if (this.dataToQuery.adminLevel != null && this.dataToQuery.adminLevel != undefined && this.dataToQuery.adminLevel.length < 1) {
                    this.dataToQuery.adminLevel=null
                }
                if (this.dataToQuery.companyId != null&&this.dataToQuery.companyId != undefined&&this.dataToQuery.companyId != '') {
                    this.dataToQuery.orgId=this.dataToQuery.companyId
                }else {
                    this.dataToQuery.orgId = sessionStorage('userId').getObject('userId').companyId
                }
                // if(this.dataToQuery.year instanceof Date){
                //     this.dataToQuery.year = this.dataToQuery.year.getFullYear().toString()
                // }
                // this.dataToQuery.year = new Date().getFullYear().toString()
                this.dataToQuery.type = 'annualProblem'
                this.queryAjax();
            },
            reset1() {
                this.dataToQuery = {
                    year1: new Date(),
                    year : new Date().getFullYear().toString()
                };
                if (this.$refs.queryOrgCascader) {
                    this.$refs.queryOrgCascader.resetCurrentOrg();
                }
                if (this.$refs.queryOrgCascader1) {
                    this.$refs.queryOrgCascader1.resetCurrentOrg();
                }
                this.pagedata.currentPage=1
                this.query()
            },
            setOrgId(data) {
                this.dataToQuery.companyId = data[data.length - 1];
            },
            querySelect() {
                this.queryMeetingSelectModal = true
            }
        },
        computed: {},

    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
</style>
